type Tdom_styles = {
    /** 选择器 */
    selectors: string;
    /** 样式 */
    styles: Tdom_style_obj;
};

interface _CD_ {
    /**
     * 创建style标签
     * @param styles 样式
     * @param formatter true: 格式化; false: 不格式化;
     * @returns style标签对象
     */
    createStyle(styles: Array<Tdom_styles>, formatter?: boolean): KHTMLElement;
}
{
    Object.defineProperty(_CD_.prototype, 'createStyle', {
        writable: false,
        configurable: false,
        enumerable: false,
        value: (stylses: Array<Tdom_styles>, formatter: boolean = true) => {
            let textContent = '';
            stylses.forEach(x => {
                const selectors = x.selectors;
                const styles = x.styles;

                let content = [];
                for (const key in styles) {
                    if (Object.prototype.hasOwnProperty.call(styles, key)) {
                        const value = styles[key];
                        content.push(`${U.S.snakeCase(key, '-').toLowerCase()}: ${value};`);
                    }
                }

                if (formatter) {
                    textContent += `${selectors} {\r\n\t${content.join('\r\n\t')}\r\n}\r\n`;
                } else {
                    textContent += `${selectors} { ${content.join(' ')} }`;
                }
            });

            return U.D.createElement('style').insertTo('head').setAttr('textContent', textContent);
        }
    });
}
